package com.bos.dao.imp;

import com.bos.dao.IUserDao;
import com.bos.dao.base.imp.BaseDaoImp;
import com.bos.domain.User;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * @author Administrator
 */
@Repository
public class IUserDaoImp extends BaseDaoImp<User> implements IUserDao {

    @Override
    public User findByUsernameAndPassword(String username, String password) {
        String hql="from User u where u.username = ? and u.password = ? ";
        List<User> user = (List<User>) this.getHibernateTemplate().find(hql,username,password);
        if (user.size() > 0 && user != null){
            return user.get(0);
        }
        return null;
    }

    @Override
    public User finByUserName(String username) {
        String hql="from User u where u.username = ?";
        List<User> user = (List<User>) this.getHibernateTemplate().find(hql,username);
        if (user.size() > 0 && user != null){
            return user.get(0);
        }
        return null;
    }
}
